<html>
<head><meta charset="utf-8"><title>Find if a proc-macro has been defined · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html">Find if a proc-macro has been defined</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213237484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237484">(Oct 14 2020 at 01:24)</a>:</h4>
<p>Hi all. I'm current working with the project-error-handling group on Tracking issue for RFC 2011: nicer assert messages <a href="https://github.com/rust-lang/rust/issues/44838">#44838</a>  <a href="https://github.com/rust-lang/rust/issues/44838">https://github.com/rust-lang/rust/issues/44838</a>   I need to determine if a procedural macro has been defined in the compiler.  Can someone point me in the direction to determine this?  Thanks in advance.</p>



<a name="213237510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237510">(Oct 14 2020 at 01:25)</a>:</h4>
<p><span class="user-mention" data-user-id="344328">@Charles Ellis O'Riley Jr.</span> maybe <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#structfield.all_macros">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#structfield.all_macros</a> ?</p>



<a name="213237521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237521">(Oct 14 2020 at 01:25)</a>:</h4>
<p>or actually <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#structfield.builtin_macros">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#structfield.builtin_macros</a> would be better I think</p>



<a name="213237604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237604">(Oct 14 2020 at 01:26)</a>:</h4>
<p>Thanks Joshua.  I'll take a look.</p>



<a name="213237612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237612">(Oct 14 2020 at 01:26)</a>:</h4>
<p>you'll need to get a <code>Resolver</code> from somewhere though</p>



<a name="213237616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237616">(Oct 14 2020 at 01:26)</a>:</h4>
<p>what part of the compiler is this?</p>



<a name="213237747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237747">(Oct 14 2020 at 01:29)</a>:</h4>
<p>Joshua, I'm new to this so I'm just going by the tracking issue.  What's a Resolver first off and is there a way I can look at the compiler to see if it currently offers what I need?</p>



<a name="213237906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237906">(Oct 14 2020 at 01:32)</a>:</h4>
<p>Oops, I just now read the issue. It looks like you don't actually need to see if <code>assert!</code> has already been defined, you just need to define it yourself. The place for that is somewhere in <a href="https://github.com/rust-lang/rust/tree/master/compiler/rustc_builtin_macros">https://github.com/rust-lang/rust/tree/master/compiler/rustc_builtin_macros</a>.</p>



<a name="213237913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213237913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213237913">(Oct 14 2020 at 01:32)</a>:</h4>
<p>(and then remove <code>assert!</code> from the standard library)</p>



<a name="213238010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238010">(Oct 14 2020 at 01:34)</a>:</h4>
<p>That part I kind of assumed but thanks for letting me feel comfortable in my assumption :)</p>



<a name="213238090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238090">(Oct 14 2020 at 01:36)</a>:</h4>
<p>Qucik question, there are different kinds of assert.  Based on your reading of the issue, would I need to just add the basic assert or the different variations of assert?  I believe what's required is the different variations based on my research.</p>



<a name="213238102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238102">(Oct 14 2020 at 01:37)</a>:</h4>
<p>from <a href="https://github.com/ishitatsuyuki/rfcs/blob/generic-assert/text/0000-generic-assert.md#how-we-teach-this">https://github.com/ishitatsuyuki/rfcs/blob/generic-assert/text/0000-generic-assert.md#how-we-teach-this</a> it seems like this new builtin macro is meant to replace all the existing ones except <code>assert!</code></p>



<a name="213238152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238152">(Oct 14 2020 at 01:38)</a>:</h4>
<p>except assert!  Can you explain?</p>



<a name="213238176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238176">(Oct 14 2020 at 01:39)</a>:</h4>
<p>so if you look at the RFC, it says</p>
<blockquote>
<p>While clippy warns about assert! usage that should be replaced by assert_eq!, it's quite annoying to migrate around.</p>
</blockquote>
<p>So a primary motivation it looks like is to reduce the number of different assert macros you need to know</p>



<a name="213238185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238185">(Oct 14 2020 at 01:39)</a>:</h4>
<p>and make <code>assert!</code> behave just as well as if you'd used <code>assert_eq</code> or <code>assert_ne</code> or any of the others</p>



<a name="213238250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Ellis O&#x27;Riley Jr. <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238250">(Oct 14 2020 at 01:40)</a>:</h4>
<p>Aaaah.  I understand.  Again, thank you very much.</p>



<a name="213238258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Find%20if%20a%20proc-macro%20has%20been%20defined/near/213238258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Find.20if.20a.20proc-macro.20has.20been.20defined.html#213238258">(Oct 14 2020 at 01:40)</a>:</h4>
<p>You're very welcome!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>